home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 1999 November / Macworld (1999-11).dmg / Updaters / WhiteCap 3.0.4 / WhiteCap Source.sit / WhiteCap Source / SJ SDK / Debug.h next >
Text File  |  1999-06-11  |  3KB  |  115 lines

  1.  
  2. /*===============================================================================
  3.  
  4.                                       Debug.h
  5.  
  6. ===============================================================================*/
  7.  
  8.  
  9. #define mtErr 0xACE
  10.  
  11. #ifndef dprintfCapable
  12.     #define dprintfCapable 0
  13. #endif
  14.  
  15. #if defined (applec) && !defined (powerc) && dprintfCapable
  16.  
  17.     #include "Exceptions.h"
  18.  
  19. #else /* THINK C, Metrowerks, etc. */
  20.  
  21.     #define DEBUGOFF        0
  22.     #define DEBUGWARN        1
  23.     #define DEBUGON            2
  24.     #define DEBUGFULL        3
  25.     
  26.     #ifndef DEBUGLEVEL
  27.         #define DEBUGLEVEL DEBUGWARN
  28.     #endif DEBUGLEVEL
  29.     
  30.     static void PlaceHolder(void);
  31.  
  32.     #define debugon (DEBUGLEVEL > DEBUGWARN)
  33.  
  34.     #define check(assertion)
  35.  
  36.     #define ncheck(assertion)
  37.  
  38.     #define check_action(assertion, action)
  39.  
  40.     #define ncheck_action(assertion, action)
  41.  
  42.     #define require(assertion, exception)                                    \
  43.         if (true) {                                                            \
  44.             if (assertion) ;                                                \
  45.             else {                                                            \
  46.                 { if (DEBUGLEVEL > DEBUGWARN)                            \
  47.                     Debugger(); }                                        \
  48.                 goto exception;                                                \
  49.             }                                                                \
  50.         } else PlaceHolder()
  51.  
  52.     #define nrequire(assertion, exception)                                    \
  53.         if (true) {                                                            \
  54.             if (assertion) {                                                \
  55.                 goto exception;                                                \
  56.             }                                                                \
  57.         } else PlaceHolder()
  58.  
  59.     #define require_action(assertion, exception, action)                    \
  60.         if (true) {                                                            \
  61.             if (assertion) ;                                                \
  62.             else {                                                            \
  63.                 { action }                                                    \
  64.                 { if (DEBUGLEVEL > DEBUGWARN)                            \
  65.                     Debugger(); }                                        \
  66.                 goto exception;                                                \
  67.             }                                                                \
  68.         } else PlaceHolder()
  69.  
  70.     #define nrequire_action(assertion, exception, action)                    \
  71.         if (true) {                                                            \
  72.             if (assertion) {                                                \
  73.                 { action }                                                    \
  74.                 goto exception;                                                \
  75.             }                                                                \
  76.         } else PlaceHolder()
  77.     
  78.  
  79. #endif
  80.  
  81. #if debugon
  82.     #if dprintfCapable
  83. /*        #define DebugMsg(theFormat) dprintf(trace, "File %s\nLine %d\n" theFormat, __FILE__, __LINE__) */
  84. /*        #define DebugMsgArg1(theFormat, arg1) dprintf(trace, "File %s\nLine %d\n" theFormat, __FILE__, __LINE__, arg1) */
  85.         #define DebugMsg(theFormat) dprintf(trace, theFormat)
  86.         #define DebugMsgArg1(theFormat, arg1) dprintf(trace, theFormat, arg1)
  87.         #define DebugMsgArg2(theFormat, arg1, arg2) dprintf(trace, theFormat, arg1, arg2)
  88.         #define DebugMsgArg3(theFormat, arg1, arg2, arg3) dprintf(trace, theFormat, arg1, arg2, arg3)
  89.     #else
  90.         #define DebugMsg(theFormat) DebugStr ((ConstStr255Param)"\p"#theFormat)
  91.         #define DebugMsgArg1(theFormat, arg1) DebugStr ((ConstStr255Param)"\p"#theFormat)
  92.         #define DebugMsgArg2(theFormat, arg1, arg2) DebugStr ((ConstStr255Param)"\p"#theFormat)
  93.         #define DebugMsgArg3(theFormat, arg1, arg2, arg3) DebugStr ((ConstStr255Param)"\p"#theFormat)
  94.     #endif
  95. #else
  96.     #define DebugMsg(theFormat)
  97.     #define DebugMsgArg1(theFormat, arg1)
  98.     #define DebugMsgArg2(theFormat, arg1, arg2)
  99.     #define DebugMsgArg3(theFormat, arg1, arg2, arg3)
  100. #endif
  101.  
  102. #define debugfull (DEBUGLEVEL > DEBUGON)
  103.  
  104. #if debugfull
  105.     #define DebugFullMsg(theFormat) DebugMsg(theFormat)
  106.     #define DebugFullMsgArg1(theFormat, arg1) DebugMsgArg1(theFormat, arg1)
  107.     #define DebugFullMsgArg2(theFormat, arg1, arg2) DebugMsgArg2(theFormat, arg1, arg2)
  108.     #define DebugFullMsgArg3(theFormat, arg1, arg2, arg3) DebugMsgArg3(theFormat, arg1, arg2, arg3)
  109. #else
  110.     #define DebugFullMsg(theFormat)
  111.     #define DebugFullMsgArg1(theFormat, arg1)
  112.     #define DebugFullMsgArg2(theFormat, arg1, arg2)
  113.     #define DebugFullMsgArg3(theFormat, arg1, arg2, arg3)
  114. #endif
  115.